<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>

<%
	request.setAttribute("title","广告详情");
    request.setAttribute("modelConfigPath", "advertisement");
%>

<%@ include file="/WEB-INF/views/shared/master/contentHeader.jsp"%>
<style type="text/css">
.content{
     margin-bottom: 28px;
  }
</style>

<t:panel cssClass="panel-flat form-detailed" customBody="true" customHead="true">
    <div class="detailed-navbar-content panel-body content">
        <t:form commandName="advertisement" action="/admin/advertisement/advertisement/save" method="post" cssClass="form-horizontal">
            <div class="hide">
                <t:hidden path="id"/>
                <t:hidden path="businessId"/>  
                <t:hidden path="createTime"/>
                <t:hidden path="createUserName"/>
                <t:hidden path="createUserId"/>
                <t:hidden path="modifyUserId"/>
                <t:hidden path="modifyUserName"/>
                <t:hidden path="modifyDate"/>
                <t:hidden path="imgUrl"/>
            </div>
             <t:formgroup>
                <t:label path="adName" cssClass="col-sm-2" />
                <t:input path="adName" colClass="col-sm-4" />
                <t:label path="isOpen" cssClass="col-sm-2" />
                <t:selectButton path="isOpen" colClass="col-sm-4" />
            </t:formgroup>
            <t:formgroup>
                <t:label path="startTime" cssClass="col-sm-2" />
                <t:datetime path="startTime" colClass="col-sm-4" />
                <t:label path="endTime" cssClass="col-sm-2" />
                <t:datetime path="endTime" colClass="col-sm-4" />
            </t:formgroup> 
            <t:formgroup>
                <t:label path="adLocationId" cssClass="col-sm-2" />
                <t:select2 path="adLocationId" colClass="col-sm-4" />
                <t:label path="href" cssClass="col-sm-2" />
                <t:input path="href" colClass="col-sm-4" />
            </t:formgroup> 
            <t:formgroup>
            <div class="col-sm-12">
               	<t:label path="imgUrl" cssClass="col-sm-2" /> 
                <div class="col-sm-2">  
               		<c:if test="${advertisement.imgUrl!=null && advertisement.imgUrl!=''}">
					    <img style="width:100px; height:80px;" id="smallPicShow" src="${tfn:getFileUrl(advertisement.imgUrl)}" /> 
				    </c:if>
				    <c:if test="${advertisement.imgUrl ==null || advertisement.imgUrl==''}">
						 <img style="width:100px; height:80px;" id="smallPicShow" src="<c:url value='/images/we/invitationIndex/bg1.jpg' />" />
				    </c:if>
				</div>
				<div class="col-sm-6">
				    <label>加载进度</label>
                      <div style="width:100px;height: 10px;margin-top:0.5rem; border: 2px solid #afafaf;border-radius:15px;"class="smallParent">
        			    <div style="width:0px;height: 7px;background-color: #afafaf" class="smallProgress"></div>
        		      </div>
					<button type="button" class="btn-info" id="deleteSmallPic" style="padding-left:10px;border-radius:6px; margin-top:1rem">删除图片</button>
                </div>
             </div>
            </t:formgroup>
            <t:formgroup>
                <t:label path="linkman" cssClass="col-sm-2" />
                <t:input path="linkman" colClass="col-sm-4" />
                <t:label path="email" cssClass="col-sm-2" />
                <t:input path="email" colClass="col-sm-4" />
            </t:formgroup>
            <t:formgroup>
                <t:label path="phone" cssClass="col-sm-2" />
                <t:input path="phone" colClass="col-sm-4" />
            </t:formgroup>
        </t:form>
    </div>
    
    <div class="navbar-fixed-bottom">
    <t:panelFoot headingBtnCssClass="heading-btn pull-right-important">
		<t:button icon="icon-floppy-disk" onclick="saveData()" cssClass="btn-info" csize="sm">保存</t:button>
	</t:panelFoot>
	</div>
</t:panel>

<script type="text/javascript">
	function saveData(){
		if (!$("form:first").valid()){
			return;
		}
		$("form:first").submit();
	}	
	
	
	
	$(function(){
		uoload();
		cancelUpload();
	})
	
	
	//上传图片
	function uoload(){
		$("#smallPicShow").on('click',function(e) {
			$(".smallProgress").width(0);
			$("#imgUrl").startCosFileUpload({
				fillImg:"#smallPicShow",
				progressCallback:function(curr, sha1){
					$(".smallParent").show();
					$(".smallProgress").width(0);
					$(".smallProgress").width(sha1*96);
				}
			});
		});	
	}
	
	//取消上传的图片
	function cancelUpload(){
		$("#deleteSmallPic").click(function(){
			var url=$.getVirtualPath()+"/admin/advertisement/advertisement/cancelUpload";
			var imgUrl=$("#imgUrl").val();
			$.post(url,{imgUrl:imgUrl},function(res){
				
				
			},'json');
			
		})
	}
	
	
</script>
<%@ include file="/WEB-INF/views/shared/base/scripts/jqueryui.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formselects.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formstyling.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formselects.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formpickers.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/dialog.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/tools/upload-cos.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/contentFooter.jsp"%>
